/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author wesleycl
 */
@Entity
@Table(name = "warrenty_contract")
@NamedQueries({@NamedQuery(name = "WarrentyContract.findAll", query = "SELECT w FROM WarrentyContract w")})
public class WarrentyContract implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
   
    
    
    @Basic(optional = false)
    @Column(name = "contract_start_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date contractStartDate;
    @Basic(optional = false)
    @Column(name = "contract_end_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date contractEndDate;


    @OneToMany(mappedBy = "warrentyContract")
    private List<MaintenanceProject> maintenanceProjectCollection;

    @JoinColumn(name = "vehicle", referencedColumnName = "id")
    @ManyToOne
    private Vehicle vehicle;

    public WarrentyContract() {
    }

    public WarrentyContract(Integer id) {
        this.id = id;
    }

    public WarrentyContract(Integer id, Date contractStartDate, Date contractEndDate) {
        this.id = id;
        
        this.contractStartDate = contractStartDate;
        this.contractEndDate = contractEndDate;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

   

    public Date getContractStartDate() {
        return contractStartDate;
    }

    public void setContractStartDate(Date contractStartDate) {
        this.contractStartDate = contractStartDate;
    }

    public Date getContractEndDate() {
        return contractEndDate;
    }

    public void setContractEndDate(Date contractEndDate) {
        this.contractEndDate = contractEndDate;
    }

    public List<MaintenanceProject> getMaintenanceProjectCollection() {
        return maintenanceProjectCollection;
    }

    public void setMaintenanceProjectCollection(List<MaintenanceProject> maintenanceProjectCollection) {
        this.maintenanceProjectCollection = maintenanceProjectCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof WarrentyContract)) {
            return false;
        }
        WarrentyContract other = (WarrentyContract) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.WarrentyContract[id=" + id + "]";
    }

    /**
     * @return the vehicle
     */
    public Vehicle getVehicle() {
        return vehicle;
    }

    /**
     * @param vehicle the vehicle to set
     */
    public void setVehicle(Vehicle vehicle) {
        this.vehicle = vehicle;
    }

}
